<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html>
<head>
    <title>人员设置</title>
    <meta name="decorator" content="form"/>
    <html:css name="bootstrap-fileinput" />
    <html:css name="simditor" />
</head>

<body class="white-bg"  formid="asigneeSettingForm">
    <form:form id="asigneeSettingForm" modelAttribute="data" method="post" action="${adminPath}/activiti/deploy/setFlowUser" class="form-horizontal">
		<form:hidden path="id" defaultValue="${param.taskDefId}"/>
		<form:hidden path="modelId" defaultValue="${param.modelId}"/>
		<table  class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
				<tr>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>任务节点名称:</label>
		            </td>
					<td class="width-35">
						<form:input path="name" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>人员类型:</label>
		            </td>
					<td class="width-35">
						<form:select path="dealingType" htmlEscape="false" class="form-control"  dict="dealingType" onchange="setTrStyle(this.value)"   />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr id="assigneeTr">
					<td  class="width-15 active text-right">	
		              <label>办理人:</label>
		            </td>
					<td class="width-35" colspan="3">
						<form:gridselect gridId="userGridId" genField="true" title="选择办理人" formField="assignee"
		   					gridField="id" path="assignee" gridUrl="${adminPath}/sys/user/selectList?multi=false" 
		   					callback="setBackVal"  labelName="assigneeName" labelValue="${data.userName }" />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr id="candidateUserTr">
					<td  class="width-15 active text-right">	
		              <label>候选人:</label>
		            </td>
					<td class="width-35" colspan="3">
						<form:gridselect gridId="userGridId" genField="true" title="选择候选人" path="candidateUser" gridUrl="${adminPath}/sys/user/selectList?multi=true" 
		   					callback="setUsersBackVal"  labelName="candidateUserName" labelValue="${data.candidateUserName }" />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr id="candidateGroupTr">
					<td  class="width-15 active text-right">	
		              <label>候选组:</label>
		            </td>
					<td class="width-35" colspan="3">
						<form:gridselect gridId="actIdGroupGridId" genField="true" title="选择候选组" path="candidateGroup" gridUrl="${adminPath}/activiti/deploy/selectGroupList" 
		   					callback="setGroupBackVal"  labelName="candidateGroupName" labelValue="${data.candidateGroupName }" />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>排序:</label>
		            </td>
					<td class="width-35" colspan="3">
						<form:input path="sortNum" htmlEscape="false" class="form-control" defaultValue="10"    />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label>短信模板:</label>
		            </td>
					<td class="width-35" colspan="3">
						<form:textarea path="sendMsgTemplet" htmlEscape="false" class="form-control" cssStyle="height:120px"     />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
		   </tbody>
		</table>   
	</form:form>
<html:js name="bootstrap-fileinput" />
<html:js name="simditor" />
<script type="text/javascript">

/**
 * @description 初始化加载JS .<br> 
 * @date 2018/7/20.<br> 
 * @author zcg .<br> 
 */
$(function(){
	var type = '${data.dealingType}';
	setTrStyle(type);
});

 /**
  * @description 根据条件设置加载 .<br> 
  * @date 2018/7/20.<br> 
  * @author zcg .<br> 
  */
function setTrStyle(value){
	if(value==1){
		$('#assigneeTr').show(); 
		$('#candidateUserTr').hide(); 
		$('#candidateGroupTr').hide(); 
	}else if(value==2){
		$('#assigneeTr').hide(); 
		$('#candidateUserTr').show(); 
		$('#candidateGroupTr').hide(); 
	}else if(value==3){
		$('#assigneeTr').hide(); 
		$('#candidateUserTr').hide(); 
		$('#candidateGroupTr').show(); 
	}else{
		$('#assigneeTr').show(); 
		$('#candidateUserTr').hide(); 
		$('#candidateGroupTr').hide(); 
	}
}

/**
 * @description 设置处理人回调 .<br> 
 * @date 2018/7/20.<br> 
 * @author zcg .<br> 
 */
function setBackVal(data){
	if(data.length>0){
		$('#assigneeName').val(data[0].realname);
	}else{
		$('#assigneeName').val('无');
	}
}

/**
 * @description 设置候选人回调 .<br> 
 * @date 2018/7/20.<br> 
 * @author zcg .<br> 
 */
function setUsersBackVal(data){
	if(data.length>0){
		var name  = new Array();
		$.each(data,function(index,item){
			name.push(item.realname);
		});
		$('#candidateUserName').val(name.join(","));
	}else{
		$('#candidateUserName').val('无');
	}
}

/**
 * @description 设置候选组回调 .<br> 
 * @date 2018/7/20.<br> 
 * @author zcg .<br> 
 */
function setGroupBackVal(data){
	if(data.length>0){
		var name  = new Array();
		$.each(data,function(index,item){
			name.push(item.name);
		});
		$('#candidateGroupName').val(name);
	}else{
		$('#candidateGroupName').val('无');
	}
}
</script>
</body>
</html>